# Contributor: Bennett Goble <nivardus@gmail.com>
# Contributor: Mike Milner <milner@blissisland.ca>
# Maintainer: John Anthony <john@jo.hnanthony.com>
pkgname=librdkafka
pkgver=2.3.0
pkgrel=1
pkgdesc="The Apache Kafka C/C++ library"
url="https://github.com/edenhill/librdkafka"
arch="all"
license="BSD-2-Clause"
makedepends="
	bsd-compat-headers
	cmake
	cyrus-sasl-dev
	lz4-dev
	openssl-dev>3
	rapidjson-dev
	samurai
	zlib-dev
	zstd-dev
	"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/edenhill/librdkafka/archive/v$pkgver.tar.gz"
options="!check" # a bunch of them fail

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=RelWithDebinfo \
		-DRDKAFKA_BUILD_EXAMPLES=OFF \
		-DRDKAFKA_BUILD_TESTS="$(want_check && echo ON || echo OFF)"
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
a68b7382ec5a9afc0eb8513e97d8563c599021d774f7790a61af80565600678a497e4957dcdd823f8b9a426a19b9c5392cacd42d02d70493d993319f3343fe96  librdkafka-2.3.0.tar.gz
"
